<?php


class HomePage extends UserDefinedForm {
	
	public static $icon = 'mysite/images/icons/homepage';
	
	public static $db = array (
		'Section1' => 'HTMLText',
		'Section2' => 'HTMLText',
		'Section3' => 'HTMLText',
		'Email' => 'VarChar(255)',
		'Skype' => 'VarChar(255)'
	);
	
	/* controls textual changes.database only holds textual information*/
	
	public static $has_many = array (
		'FolioWorks' => 'FolioImage'
	);

	
	/* kept in image table of database which is referenced by the $has_many variable */
	
	public function getCMSFields() 
	{
		$fields = parent::getCMSFields();
		/*using getCMSFields return value as my own*/
		
		$fields->addFieldToTab('Root.Content', new Tab('Section1'), 'Metadata');
		$fields->addFieldToTab('Root.Content', new Tab('Section2'), 'Metadata');
		$fields->addFieldToTab('Root.Content', new Tab('Section3'), 'Metadata');
		/*creates new tab in cms admin area*/
		
		$fields->addFieldToTab('Root.Content.Section1', new HtmlEditorField('Section1', 'Section 1 Content'));
		$fields->addFieldToTab('Root.Content.Section2', new HtmlEditorField('Section2', 'Section 2 Content'));
		
		$folioCTF = new OrderableComplexTableField($this, 'FolioWorks', 'FolioImage');
		$fields->addFieldToTab('Root.Content.Section2', $folioCTF);
		
		$fields->addFieldToTab('Root.Content.Section3', new HtmlEditorField('Section3', 'Section 3 Content'));
		$fields->addFieldToTab('Root.Content.Section3', new TextField('Email', 'Email Address'));
		$fields->addFieldToTab('Root.Content.Section3', new TextField('Skype', 'Skype Name'));
		
		
		return $fields;
		
	}

}

class HomePage_Controller extends UserDefinedForm_Controller {

	public function init() {
		
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript('themes/buzznut/javascript/hover-state.js');
		Requirements::javascript('themes/buzznut/javascript/hoverIntent.js');
		Requirements::javascript('themes/buzznut/javascript/jquery.lightbox-0.5.js');
		Requirements::javascript('themes/buzznut/javascript/scroll-effect.js');
        Requirements::javascript('themes/buzznut/javascript/facebox.js');
	
		parent::init();
	}
	


}